using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.ComponentModel;
using System.Data.Linq.Mapping;

namespace CapstoneMockup.Data
{
    [Table]
    public class User
    {
        public int Id { get; private set; }
        private static int _identity;
        public string _username;
        public string _password;
        public string _email;
        public ObservableCollection<ExpenseLog> _expenseLogs { get; private set; }
        public ObservableCollection<Timestamps> _hourTimeStamps { get; private set; }

        public ExpenseLog _currentLog = null;

        public User(string userName, int id)
        {
            _identity++;
            Id = id;
            _username = userName;
            _expenseLogs = new ObservableCollection<ExpenseLog>();
            _hourTimeStamps = new ObservableCollection<Timestamps>();
            
        }

        public User(int id, string userName, string email, ObservableCollection<ExpenseLog> expenseLogs, ObservableCollection<Timestamps> timestampLogs)
        {
            Id = id;
            _username = userName;
            _email = email;
            _expenseLogs = expenseLogs;
            _hourTimeStamps = timestampLogs;
        }

        public void NewExpenseLog(string nameOfLog)
        {
            _expenseLogs.Add(new ExpenseLog(nameOfLog));
        }

        public void NewTimeStamp(Timestamps timestamp)
        {
            _hourTimeStamps.Add(timestamp);
        }

        public void RefreshLogFile(ExpenseLog log)
        {
            foreach (ExpenseLog expenselog in _expenseLogs)
            {
                if (log._nameOfLog == _currentLog._nameOfLog)
                {
                    log = _currentLog;
                }
            }
        }
    }
}
